const { contextBridge, ipcRenderer } = require('electron');

// 安全地暴露API给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  showOpenDialog: () => ipcRenderer.invoke('show-open-dialog'),
  getFileInfo: (filePath) => ipcRenderer.invoke('get-file-info', filePath),
  compressFile: (filePath) => ipcRenderer.invoke('compress-file', filePath),
  saveAndCompressFile: (fileName, fileData) => ipcRenderer.invoke('save-and-compress-file', fileName, fileData),
  checkFileSize: (filePath) => ipcRenderer.invoke('check-file-size', filePath),
  deleteFile: (filePath) => ipcRenderer.invoke('delete-file', filePath)
});

// 添加日志
console.log('preload.js 已加载，electronAPI 已暴露');